package ru.niir.goodfil.audit.domain;

import ru.niir.goodfil.audit.domain.enums.Crud;
import ru.niir.goodfil.audit.util.Assert;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;

@Entity
public class EntityEvent extends Event {
    @Column(length = 255)
    private String klass;

    @Enumerated(EnumType.STRING)
    private Crud crud;

    @Column(length = 10000)
    private String xmlContent;

    private EntityEvent() {
    }

    public EntityEvent(String ip, String login, Crud crud, String klass, String xmlContent) {
        Assert.notBlank(login);
        Assert.notBlank(ip);
        Assert.notNull(crud);
        Assert.notBlank(klass);
        Assert.notBlank(xmlContent);

        this.crud = crud;
        this.klass = klass;
        this.xmlContent = xmlContent;
        this.login = login;
        this.ip = ip;
    }

    public Crud getCrud() {
        return crud;
    }

    public void setCrud(Crud crud) {
        this.crud = crud;
    }

    public String getXmlContent() {
        return xmlContent;
    }

    public void setXmlContent(String xmlContent) {
        this.xmlContent = xmlContent;
    }

    public String getKlass() {
        return klass;
    }

    public void setKlass(String klass) {
        this.klass = klass;
    }

    @Override
    public String toString() {
        return "EntityEvent{" +
                "klass='" + klass + '\'' +
                ", crud=" + crud +
                ", xmlContent='" + xmlContent + '\'' +
                '}';
    }
}
